import Vue from 'vue'
import Vuex from 'vuex'
import menus from "./modules/menus";

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    token: '',
    userInfo: {
      username: '',
      avatar: '',
      id: ''
    }
  },
  mutations: {
    setToken: (state, token) => {
      state.token = token
      localStorage.setItem('token', token)
    },
    resetState: (state) => {
      state.menus.editableTabs = [{
        title: '首页',
        name: 'Index'
      }]
      state.menus.editableTabsValue = 'Index'
    },
    log_userInfo: (state, userInfo) => {
      state.userInfo.username = userInfo.username;
      state.userInfo.avatar = userInfo.avatar;
      state.userInfo.id = userInfo.id;
    }
  },
  actions: {
  },
  modules: {
    menus
  }
})
